package com.neusoft.dibuy.tyut.net.client;

import com.neusoft.dibuy.tyut.net.cfg.NetConfig;

import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
import java.nio.charset.StandardCharsets;
import java.util.Date;

public class ClientDemo1 {
    public static void main(String[] args) throws  IOException {
        Socket socket = new Socket( NetConfig.MSG_SERVER , NetConfig.MSG_PORT);
        System.out.println("客户端连接成功");
        OutputStream os = socket.getOutputStream();
        String msg = "你好，我是客户端 ，现在是  " +   new Date();
        byte[] bs = msg.getBytes(StandardCharsets.UTF_8);
        os.write(bs);
//        强制清理缓存；
        os.flush();
        os.close(); // close =  flush + close;
        socket.close();
    }
}
